package com.example.demo.entity;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;

/**
 * @Desc
 * @Author zxp
 * @Date 2024/3/17
 */
@Entity(tableName = "tb_user")  // 指定为room的数据库实体类，指定表名
public class User {

    @PrimaryKey(autoGenerate = true)  // 主键，也可在Entity里指定，设置是否自动生成主键（不知道为什么，设置成false也会自动生成2.3.0）
    @ColumnInfo(name = "id")  // 指定表字段的名称
    private Long id;

    private String name;

    private Integer age;

    @Ignore  // 忽略该字段
    private String xx;

    public User() {
    }

    @Ignore  // 多个构造函数，非无参构造函数需要加Ignore
    public User(Long id, String name, Integer age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", xx='" + xx + '\'' +
                '}';
    }
}
